﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO;
using OpenLS.Spreadsheet.Formats.Biff.OfficeArt;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class MsoDrawingSelectionRecord : BiffRecord
    {
        private OfficeArtFDGSL _selection;


        protected override void ReadContent(BiffReaderContext context, int length)
        {
            _selection = new OfficeArtFDGSL();
            _selection.Read(context.Reader, length);
        }


        internal override BiffRecordType RecordType
        {
            get { return BiffRecordType.MsoDrawingSelection; }
        }

        internal override void WriteContent(BiffWriterWorkbookContext context)
        {

            _selection.Write(new OfficeArtWriteContext(context.Writer, null));
        }
    }
    internal class OfficeArtFDGSL
    {
        private OfficeArtRecordHeader rh;
        private uint cpsp;
        private uint dgslk;
        private uint spidFocus;
        List<uint> shapeList = new List<uint>();

        public void Read(BinaryReader reader, int recordLength)
        {
            this.rh = new OfficeArtRecordHeader();
            this.rh.Read(reader);
            this.cpsp = reader.ReadUInt32();
            this.dgslk = reader.ReadUInt32();
            this.spidFocus = reader.ReadUInt32();
            int shapeListCount = ((recordLength - 20)/4);
            Contract.Assert(shapeListCount * 4 == recordLength - 20);
            for (int i = 0; i < shapeListCount; i++)
            {
                shapeList.Add(reader.ReadUInt32());
            }
        }

        public void Write(OfficeArtWriteContext writer)
        {
            rh.Write(writer.Writer);
            writer.Write(cpsp);
            writer.Write(dgslk);
            writer.Write(spidFocus);
            throw new NotImplementedException();
        }
    }
}